package algorithm.minitree;

import java.util.Vector;

/**
 * @author bingo
 * @Description
 * @Date 2018/4/15
 */
public class
Main {

    // 测试通过文件读取图的信息
    public static void main(String[] args) {

        // 使用两种图的存储方式读取testG1.txt文件
        String filename = "demo/other.example.txt";
        SparseWeightedGraph<Double> g1 = new SparseWeightedGraph<Double>(8, false);
        ReadWeightedGraph readGraph1 = new ReadWeightedGraph(g1, filename);
        System.out.println("frame G1 in Sparse Weighted Graph:");
        g1.show();

        System.out.println();

        DenseWeightedGraph<Double> g2 = new DenseWeightedGraph<Double>(8, false);
        ReadWeightedGraph readGraph2 = new ReadWeightedGraph(g2 , filename );
        System.out.println("frame G1 in Dense Graph:");
        g2.show();

        System.out.println();
       /**prim算法最小生成树*/
       LazyPrimMST lazyPrimMST = new LazyPrimMST(g1);
       Double mstWeight = (Double)lazyPrimMST.getMstWeight();
        Vector<Edge> vector = lazyPrimMST.getMst();
        for(Edge e : vector){
            System.out.println(e.a()+"->"+e.b()+"::"+e.wt());
        }
        System.out.println("prim算法最小生成树:"+mstWeight);


        /**kruskalMST算法最小生成树*/
        KruskalMST kruskalMST = new KruskalMST(g1);
        Double mstWeight2 = (Double)kruskalMST.getMstWeight();
        Vector<Edge> vector2 = kruskalMST.getMst();
        for(Edge e : vector2){
            System.out.println(e.a()+"->"+e.b()+"::"+e.wt());
        }
        System.out.println("kruskalMST算法最小生成树:"+mstWeight2);


    }




}
